package com.wenchao.quickstart.utils;

import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

public final class InputMethodTool {
    private static final Object lock = new Object();
    private static volatile InputMethodTool instance;

    private InputMethodTool() {
    }

    public static InputMethodTool instance() {
        if (instance == null) {
            synchronized(lock) {
                if (instance == null) {
                    instance = new InputMethodTool();
                }
            }
        }

        return instance;
    }

    public void hideInputSoftFromWindowMethod(Context context, View view) {
        try {
            InputMethodManager imm = (InputMethodManager)context.getSystemService("input_method");
            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
        } catch (Exception var4) {
            var4.printStackTrace();
        }

    }

    public void showInputSoftFromWindowMethod(Context context, View view) {
        try {
            InputMethodManager imm = (InputMethodManager)context.getSystemService("input_method");
            imm.showSoftInput(view, 2);
        } catch (Exception var4) {
            var4.printStackTrace();
        }

    }

    public boolean isActiveSoftInput(Context context) {
        InputMethodManager imm = (InputMethodManager)context.getSystemService("input_method");
        return imm.isActive();
    }
}